package com.xxq.semester.common.entity;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

/**
 * 统一响应实体类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseEntity<T> {
    private int code;
    private String message;
    private T data;
    
    public static <T> ResponseEntity<T> success() {
        return new ResponseEntity<>(200, "操作成功", null);
    }
    
    public static <T> ResponseEntity<T> success(T data) {
        return new ResponseEntity<>(200, "操作成功", data);
    }
    
    public static <T> ResponseEntity<T> success(String message, T data) {
        return new ResponseEntity<>(200, message, data);
    }
    
    public static <T> ResponseEntity<T> fail(String message) {
        return new ResponseEntity<>(500, message, null);
    }
    
    public static <T> ResponseEntity<T> fail(int code, String message) {
        return new ResponseEntity<>(code, message, null);
    }
}
